package com.x.provider.oss.controller.admin;

import com.x.core.web.api.R;
import com.x.core.web.controller.BaseAdminController;
import com.x.provider.api.oss.model.dto.green.AddGreenNotifyRequestDTO;
import com.x.provider.oss.model.bo.GreenContentRequestBO;
import com.x.provider.oss.service.ContentGreenService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@Slf4j
@Api(tags = "内容审核")
@RestController
@RequestMapping("/admin/green")
public class GreenAdminController extends BaseAdminController {

    private final ContentGreenService contentGreenService;

    public GreenAdminController(ContentGreenService contentGreenService){
        this.contentGreenService = contentGreenService;
    }

    @PostMapping("/content")
    public R<Void> greenContent(@RequestBody GreenContentRequestBO greenContentRequestBO) throws IOException {
        contentGreenService.greenContent(greenContentRequestBO);
        return R.ok();
    }

    @PostMapping("/result/update")
    public R<Void> updateContentGreenResult(){
        contentGreenService.updateContentGreenResult();
        return R.ok();
    }

    @PostMapping("/content/notify")
    public R<Void> notifyContentGreenResult(){
        contentGreenService.notifyContentGreenResult();
        return R.ok();
    }

    @PostMapping("/notify/add")
    public R<Void> addContentGreenResultNotify(@RequestBody AddGreenNotifyRequestDTO addGreenNotifyRequestDTO){
        contentGreenService.addGreenNotify(addGreenNotifyRequestDTO);
        return R.ok();
    }
}
